<template>
  <section class="function-section">
    <h2 class="section-title">
      <span>高级修</span>
    </h2>
    
    <div class="price-options">
      <div 
        v-for="(option, index) in priceOptions" 
        :key="index"
        :class="['price-item', { active: selectedPrice === index }]"
        @click="selectPrice(index)"
      >
        <span class="currency">¥</span>
        <span class="amount">{{ option.amount }}</span>
        <span class="suffix">起</span>
      </div>
    </div>
    
    <button class="main-action" @click="handleSubmit">
      <Sparkles :size="18" />
      <span>帮我修图</span>
    </button>
    
    <div class="terms-container">
      <div class="checkbox-wrapper">
        <input 
          type="checkbox" 
          id="terms-checkbox" 
          v-model="termsAccepted"
          class="terms-checkbox"
        >
        <label for="terms-checkbox" class="checkbox-label"></label>
      </div>
      <label for="terms-checkbox" class="terms-text">
        <span class="terms-clickable">点击即表示同意</span>
        <a href="#" class="terms-link" @click.stop.prevent="handleTermsClick">服务条款</a>
        <span class="terms-clickable">和</span>
        <a href="#" class="terms-link" @click.stop.prevent="handlePrivacyClick">隐私政策</a>
        <br>
        <span class="terms-clickable">我们严格保护您的隐私安全</span>
      </label>
    </div>
  </section>
</template>

<script>
import { Sparkles } from 'lucide-vue-next'

export default {
  name: 'PriceSection',
  components: {
    Sparkles
  },
  props: {
    defaultSelectedPrice: {
      type: Number,
      default: 1
    }
  },
  emits: ['submit', 'priceChange'],
  data() {
    return {
      selectedPrice: this.defaultSelectedPrice,
      termsAccepted: true,
      priceOptions: [
        { amount: 5 },
        { amount: 15 },
        { amount: 30 }
      ]
    }
  },
  watch: {
    defaultSelectedPrice(newValue) {
      if (newValue !== this.selectedPrice) {
        this.selectedPrice = newValue
      }
    }
  },
  methods: {
    selectPrice(index) {
      if (this.selectedPrice !== index) {
        this.selectedPrice = index
        this.$emit('priceChange', index)
      }
    },
    
    handleSubmit() {
      if (!this.termsAccepted) {
        alert('请先同意服务条款和隐私政策')
        return
      }
      
      this.$emit('submit', {
        price: this.priceOptions[this.selectedPrice].amount,
        termsAccepted: this.termsAccepted
      })
    },
    
    handleTermsClick() {
      console.log('打开服务条款')
    },
    
    handlePrivacyClick() {
      console.log('打开隐私政策')
    }
  }
}
</script>

<style scoped>
.function-section {
  padding: 32px 16px;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: none;
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
  text-align: center;
  margin-bottom: 24px;
  padding-top: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.section-title::before,
.section-title::after {
  content: '';
  width: 60px;
  height: 1px;
  background: linear-gradient(to var(--gradient-dir), 
    transparent 0%, 
    rgba(255, 107, 53, 0.6) 50%, 
    rgba(255, 107, 53, 0.3) 100%);
}

.section-title::before {
  --gradient-dir: right;
}

.section-title::after {
  --gradient-dir: left;
}

.price-options {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 24px;
}

.price-item {
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.price-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

.price-item.active {
  background: rgba(255, 107, 53, 0.15);
  border-color: #FF6B35;
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

.price-item.active:active {
  transform: scale(0.98);
}

.currency {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 400;
  opacity: 0.9;
}

.amount {
  font-size: 20px;
  font-weight: 600;
  color: white;
}

.suffix {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 400;
  opacity: 0.9;
}

.main-action {
  width: 100%;
  padding: 18px;
  background: linear-gradient(135deg, #FF6B35 0%, #F7931E 100%);
  color: white;
  border: none;
  border-radius: 26px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 
    0 6px 20px rgba(255, 107, 53, 0.4),
    0 2px 8px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.main-action:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 8px 25px rgba(255, 107, 53, 0.5),
    0 4px 12px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.main-action:active {
  transform: translateY(0);
  box-shadow: 
    0 4px 15px rgba(255, 107, 53, 0.4),
    0 2px 6px rgba(0, 0, 0, 0.2),
    inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.main-action::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.5s ease;
}

.main-action:active::before {
  transform: translate(-50%, -50%) scale(1);
}

.terms-container {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  width: 100%;
  text-align: center;
}

.checkbox-wrapper {
  margin-top: 2px;
  flex-shrink: 0;
}

.terms-checkbox {
  display: none;
}

.checkbox-label {
  display: block;
  width: 16px;
  height: 16px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
}

.checkbox-label::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  background: #FF6B35;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.2s ease;
}

.terms-checkbox:checked + .checkbox-label::after {
  transform: translate(-50%, -50%) scale(1);
}

.checkbox-label:hover {
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.1);
}

.terms-text {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.4;
  margin: 0;
  cursor: pointer;
  user-select: none;
}

.terms-clickable {
  cursor: pointer;
}

.terms-link {
  color: #FF6B35;
  text-decoration: none;
  cursor: pointer;
}

.terms-link:hover {
  text-decoration: underline;
  color: #FF8855;
}
</style>